############################################################################
# Tidy 1.0 Configuration File
#
# COPYRIGHT (C) 1996 Marek Rouchal

############################################################################
# IMPORTANT!
# You may change the values in this file in order to customize the
# behavior of tidy. Do NOT remove the if/unless functions, otherwise
# command line settings won't work. This is because command line options
# are evaluated before looking at this file. This isn't pretty, but
# it simplifies things for me :)
# And: Please stick to the valid settings. Everything else will
#      produce ugly unpredictable results.

############################################################################
# Paths & Files

# This is where syslog puts its messages.
# on linux systems it is often /var/adm/MAIL
$LOGFILE = "/var/adm/MAIL" unless $LOGFILE;

# This specifies the database File where statistics are stored
# you might say /var/adm/tidy.db here if you intend to run tidy as
# the super-user
$DBFILE = "/var/adm/tidy.db" unless $DBFILE;

# This is the path to the statistics output files
# This is automatically overridden when the -o command line option
# is used.
$OUTDIR = $ENV{'PWD'} || ".";

# These are the default statistics output filenames
# if no -o option is given
$OUTFILE_ASCII = "tidy.txt";
$OUTFILE_HTML  = "tidy.html";

###########################################################################
# Statistics output format settings
# ... determine the design of the statistics output file

# This specifies the default output format
# valid settings are "none", "ascii" and "html"
# "none" means that no output is produced. However, tidy still
#        tidies the log file and saves statistics to the database
# "ascii" produces basic text-only output.
# "html"  produces neat tables. You need a browser that handles <TABLE>
#         to view them. Netscape higher than 1.1 is OK.
$OUTPUT = "ascii" unless $OUTPUT;

# This is the time (of last contact) configuration.
# valid settings are "none", "short", "long"
# "short" is e.g. '19:21'
# "long"  is e.g. '19:21:13'
$FORM_TIME = "short" unless $FORM_TIME;

# This is the date (of last contact) configuration
# valid settings are "none", "short", "long"
# "short" is e.g. '04/24'
# "long"  is e.g. 'Apr 24'
$FORM_DATE = "long" unless $FORM_DATE;

# This defines whether the time/date stamps should be printed
# besides or below the number of remote host contacts
# If you are short of width (80 columns), you'd prefer "below"
# valid settings are "besides" and "below"
$ORIENTATION = "below" unless $ORIENTATION;

# This has different meanings in the ASCII and HTML context:
# ASCII: This specifies whether a ruler line consisting of
# "-----+-----" should be inserted after each entry when printing the
# statistics. You may want it when you are printing time and date to
# enhance readability.
# HTML: If $RULER is set to "on", tidy will produce one
# huge table. I noticed that e.g. Netscape for Windows had
# problems in displaying a 180k table. $RULER set to "off"
# will produce small tables of $PAGER_LINES length.
# valid settings are "on" and "off"
$RULER = "on" unless $RULER;

# This gives the number of lines after that the header
# is printed again to the outfile so that the
# columns can be easier distinguished.
# Zero value means printing of the header only at the
# very beginning of the statistics file.
$PAGER_LINES = 15 if (!defined($PAGER_LINES) );

# This is the sortkey for the statistics output.
# valid settings are "none", "host", "domain" and the
# keywords listed below in the CATEGORY section.
# "none" means no sorting, entries will appear in an arbitrary order
# "host" means sort by host name
# "domain" means sort by domains, i.e. foo.bar.de is sorted as de.bar.foo
# If you specify a keyword listed below, then hosts are sorted by the
# number of contacts (highest numbers first)
$SORTKEY = "host" unless $SORTKEY;

# Shall the hosts/domains be sorted regardless of upper/lower case letters?
# "off" means case insensitive, "on" means case sensitive
$CASE_SENSITIVE = "off" unless $CASE_SENSITIVE;

############################################################################
# Logfile Categories/Services

# These are the categories which (may) appear in the log file created
# by syslogd. You will probably want to change this. Just read the
# following paragraph, look at the defaults and change them. If you
# have problems with Regexp's (regular expressions), refer to the
# perlre man page.
#
# Categories are indexed with a keyword, which may be referred to by $SORTKEY.
#
# Each category consists of 6 entries:
#  1. Priority. Categories with higher priority (i.e. LOWER
#     number) are searched for first. This can result in better
#     log file processing performance if this category appears
#     often in the log file. This number also specifies in which
#     column the category appears in the output.
#  2. Regexp for ident string. The ident string is typically the name
#     of the program that called syslog (e.g. sendmail, in.telnetd).
#     Syslog often adds the PID. This is being recognized automatically
#     by tidy, so you don't have to give it here. See also syslog(3).
#  3. Regexp to extract remote host name from message. These look
#     rather ugly (esp. for sendmail), but they do their job, i.e. to
#     search the entire message string (e.g. 'connect from foo.bar.dom')
#     for the remote host name contained in the message (e.g. 'foo.bar.dom').
#     The remote host name must be written to $1
#     It requires some knowledge of RE's to construct this entry, but
#     this way almost every possibility can be covered. Refer to
#     the perlre man page if you don't understand what happens below.
#  4. Regexp. Entry will be discarded if it matches. Tidy will first try
#     to extract a remote host with the RE above. If this fails, it may
#     still be possible that the message contains no important
#     information (e.g. sendmail to local users, unsuspicious errors)
#     that you want to be discarded from the log file.
#  5. Table heading string for ASCII output
#     This should be readable when only the first four chars of it
#     are printed. A column is only 4 chars wide when there is no
#     time/date output!
#  6. Caption string for HTML output
#     You may add additional format information for the <TH> directive,
#     i.e. supply the string, which will fit here: "<TH $your_string</TH>"
#     Be sure to give at least "> Telnet", for example. This is because
#     eventually "<TH COLSPAN=2" is used.

# For those completely unfamiliar to RE's, I'll explain what happens here.
# Consider 'connect from \s+(\S+).*$'
# The message string is searched for the string 'connect from', followed
# by an arbitrary amount of whitespace ( '\s+' the '+' means that at least
# one char of whitespace must be present, '\s' stands for space or tab)
# '(\S+)' matches as much non-whitespace as possible. The '()' will
# generate a back reference, i.e. the string matched by '\S+' will be
# saved to $1 which is then used by tidy.
# '.*$' matches anything that comes after the non-whitespace. This is
# done by the '.*' part, where '.' matches any character and '*' means
# any number of occurrences, including 0.

$CATEGORY{'TELNET'}   = [ 1, 'in.telnetd',
                         'connect from\s+(\S+).*$',
                         '', 'TELNT', '><I>Telnet</I>' ];
$CATEGORY{'RLOGIN'}   = [ 2, 'in.rlogind',
                         'connect from\s+(\S+).*$',
                         '', 'RLOGN', '><I>Rlogin</I>' ];
$CATEGORY{'FTP'}      = [ 3, 'wu.ftpd', 
                         'connect from\s+(\S+).*$',
                         '', 'FTP', '><I>FTP</I>' ];

# In order to better understand what the following is about, look at this
# line from the syslogd-logfile. Remember that you want to get
# 'freenet.uni-bayreuth.de; in this case, but only if the message really has
# been sent! (The rest of the comment was originally one line!)
# '(?:  )' means simply that the result of '()' isn't saved as a back
# reference.
# Original line from log file:
# Feb 21 17:42:53 saftsack sendmail[1300]: RAA01299: 
# to=a0123@freenet.uni-bayreuth.de, ctladdr=marek (408/100), delay=00:00:29, 
# mailer=smtp, relay=freenet.uni-bayreuth.de. [132.180.15.7], 
# stat=Sent (RAA23561 Message accepted for delivery)

$CATEGORY{'MAILTO'}     = [ 4, 'sendmail',
                 '^.* to=.*?\@(\S+?)(?:>,|,).*stat=Sent.*$',
                           ' to=', # the space is vitally important!

# This is because sendmail lines may contain a 'proto=', which
# of course is matched by /to=/. This would cancel the 'MAILFROM' entries.

                           'M_TO', '><I>Mail To</I>' ];
$CATEGORY{'MAILFROM'}     = [ 5, 'sendmail',
                         '^.* from=.*?\@(\S+?)(?:>,|,).*$',
                         ' from=', 'M_FR', '><I>Mail From</I>' ];

# The 'TALK' category matches entries from both
# talkd and ntalkd

$CATEGORY{'TALK'}     = [ 6, '(in.talkd|in.ntalkd)',
                         'connect from\s+(\S+).*$',
                         '', 'TALK', '><I>Talk</I>' ];
$CATEGORY{'FINGER'}   = [ 7, '(in.fingerd|in.kfingerd)',
                         'connect from\s+(\S+).*$',
                         '', 'FINGR', '><I>Finger</I>' ];
# Maybe you won't ever need this one
$CATEGORY{'RSH'}      = [ 8, 'in.rshd',
                         'connect from\s+(\S+).*$',
                         '', 'RSHLL', '><I>Remote Shell</I>' ];

# This is the table header for the "Remote Host" column, HTML only
$REMOTE_HEADER = "<TH ALIGN=LEFT><I>Remote Host</I></TH>";

###########################################################################
# Host name aliasing

# This hash serves to cast host names to other names. This is useful if
# aliases of one host exist and you do not want them to become separate 
# entries in your statistics.
# You can also use this to cast IP addresses to more meaningful names or
# lots of similar terminals to one general entry.
# Sample:
# %HOSTNAME_ALIAS = ( 'saftsack.fs.uni-bayreuth.de' => 'localhost',
#                     'btfmd2.fs.uni-bayreuth.de'   => 'localhost' );
#
%HOSTNAME_ALIAS = ( );

###########################################################################
# This are the headers and trailers for output
# You may use the names $CREATION_DATE and $LAST_UPDATE
# Their meaning should be clear :)
# $LOG_REMOTE is the number of processed logfile lines that contained
# remote hosts, $LOG_DISCARD is the number of lines discarded by the
# 2nd RE. $TOTAL_REMOTE is the number of remote hosts in the current
# database.
# Be sure to escape the '$', i.e. \$, as these strings are eval'ed

@ASCII_HEADER = (
	"Remote hosts contacts statistics",
	"================================",
	"",
	"for <localhost>",             # you WANT to edit this!
	"",
	"Database created \$CREATION_DATE",
	"Last updated     \$LAST_UPDATE",
	"",
	"Processed lines: with remote host contacts: \$LOG_REMOTE",
    "                 discarded lines:           \$LOG_DISCARD",
	"",
	"Total number of remote hosts: \$TOTAL_REMOTE",
	"",
	"These statistics were created by tidy 1.0",
	"" );

@ASCII_TRAILER = (
	"",
	"These statistics were created by tidy 1.0",
	"written by M. Rouchal, University of Bayreuth, Germany",
	"tidy is freely available from its official ftp site:",
	"ftp://saftsack.fs.uni-bayreuth.de/pub/tidy/" );

@HTML_HEADER = (
	"<HTML><HEAD><TITLE>Remote Hosts Contact Statistics</TITLE></HEAD>",
	"<BODY><H1>Remote Hosts Contact Statistics</H1>",
	"<HR>",
	"<I>Local Host:</I> localhost<P>",       # you WANT to edit this!
	"<I>Database created</I> \$CREATION_DATE<BR>",
	"<I>Last updated</I> \$LAST_UPDATE<P>",
	"<I>Processed lines:</I><BR>",
	"<I>... with remote host contacts:</I> \$LOG_REMOTE<BR>",
    "<I>... discarded lines:</I> \$LOG_DISCARD<P>",
	"<I>Total number of remote hosts:</I> \$TOTAL_REMOTE<P>",
	"These statistics were created by <A HREF=\\\"#tidy\\\">tidy 1.0</A>.",
	"<HR>" );

@HTML_TRAILER = (
	"<HR>",
	"<A NAME=\\\"tidy\\\"></A>These statistics were created by tidy 1.0<BR>",
	"written by <I>M. Rouchal</I>, University of Bayreuth, Germany<P>",
	"Comments and bug reports are welcome. Please refer to<BR>",
	"<I><A HREF=\\\"mailto:marek\\\@saftsack.fs.uni-bayreuth.de\\\">",
	"marek\\\@saftsack.fs.uni-bayreuth.de</A></I><P>",
	"<I>tidy</I> is freely available from its",
	"<A HREF=\\\"http://saftsack.fs.uni-bayreuth.de/~marek/tidy/index.html\\\">WWW Home Page</A><P>",
	"</BODY></HTML>" );

###########################################################################
# This is needed for the translation of dates

%MONTH_STR_TO_NUM = ( 'Jan' => '01', 'Feb' => '02', 'Mar' => '03',
		'Apr' => '04', 'May' => '05', 'Jun' => '06',
		'Jul' => '07', 'Aug' => '08', 'Sep' => '09',
		'Oct' => '10', 'Nov' => '11', 'Dec' => '12' );

@MONTH_NUM_TO_STR = ( '???', 'Jan', 'Feb', 'Mar',
		'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
		'Oct', 'Nov', 'Dec' );

###########################################################################
# END OF CONFIGURATION FILE - do not alter anything below this line
1;

